import java.util.Arrays;
import java.util.List;


public class ArraysAsList {

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		String[] array = {"Milo", "Nakov", "Martin"};
		printList(Arrays.asList(array)); 
		printList(Arrays.asList("Milo", "Nakov", "Martin"));
		printList(Arrays.asList(array, "Milo")); //bad usage
		
		List<String> list = Arrays.asList(array);
		list.set(1, "Svetlin");
		System.out.println(Arrays.toString(array));
		
		String[] b = new String[list.size()-1];
		String[] c = list.toArray(b);
		System.out.println(Arrays.toString(b));
		System.out.println(Arrays.toString(c));
		
//		list.add("New lector"); // UnsupportedOperationException exception is thrown

	}
	@SuppressWarnings("unchecked")
	public static void printList(List list){
		for(Object o : list){
			System.out.println(o);
		}
		System.out.println();		
	}

}
